using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class AdminInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Username,
			Password,
			FullName,
			Email
		}
		private Int32 _ID;
		private String _Username;
		private String _Password;
		private String _FullName;
		private String _Email;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String Username{	get{ return _Username;} set{_Username = value;} }
		public String Password{	get{ return _Password;} set{_Password = value;} }
		public String FullName{	get{ return _FullName;} set{_FullName = value;} }
		public String Email{	get{ return _Email;} set{_Email = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public AdminInfo()
		{
			_ID = 0;
			_Username = "";
			_Password = "";
			_FullName = "";
			_Email = "";
		}
		public AdminInfo(
		Int32 ID,
		String Username,
		String Password,
		String FullName,
		String Email
		)
		{
			_ID = ID;
			_Username = Username;
			_Password = Password;
			_FullName = FullName;
			_Email = Email;
		}
		public AdminInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_Username = dr[Field.Username.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Username.ToString()]);
				_Password = dr[Field.Password.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Password.ToString()]);
				_FullName = dr[Field.FullName.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.FullName.ToString()]);
				_Email = dr[Field.Email.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Email.ToString()]);
			}
		}
		public AdminInfo(AdminInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Username = objEntr.Username;			
			_Password = objEntr.Password;			
			_FullName = objEntr.FullName;			
			_Email = objEntr.Email;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Admin");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.Username.ToString(), typeof(String)),
				new DataColumn(Field.Password.ToString(), typeof(String)),
				new DataColumn(Field.FullName.ToString(), typeof(String)),
				new DataColumn(Field.Email.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Username.ToString()] = _Username;
			row[Field.Password.ToString()] = _Password;
			row[Field.FullName.ToString()] = _FullName;
			row[Field.Email.ToString()] = _Email;
			return row;
		}
        #endregion InitTable
    }
}
